<?php

ini_set('display_errors', 1);
ini_set('log_errors', 1);
ini_set('error_log', dirname(__FILE__) . '/error_log.txt');
error_reporting(E_ALL);
define("MODELE_DIR", "../../modeles/");
define("LIB_DIR", "../../libs/");
require_once(MODELE_DIR . 'Dimension1.php');
require_once(MODELE_DIR . 'Dimension2.php');
require_once(MODELE_DIR . 'Dimension3.php');
require_once(MODELE_DIR . 'Dimension4.php');
require_once(MODELE_DIR . 'Type.php');

session_start();
if (isset($_SESSION['document'])) {
    $dimension = $_SESSION['document']['options'];
    //print_r($_SESSION['document']['options']);
    define("POLICE", "Times");
    require(LIB_DIR . 'fpdf/rounded_rect.php');

    $pdf = new PDF();
    $pdf->SetAutoPageBreak(true, 15);
    $pdf->AliasNbPages();
    $pdf->SetFont(POLICE, "");
    $pdf->AddPage();
    $pdf->SetLineWidth(0.6);
    $pdf->SetFillColor(251);


    $pdf->AjouterTitre($_SESSION['document']['titre']);
    $pdf->AjouterPartieLibre($_SESSION['document']['cadre2']);
    $pdf->AjouterPartieLibre($_SESSION['document']['cadre3']);
    $dimension = unserialize(urldecode($dimension));
    
    foreach ($dimension as $dim) {
        foreach ($dim->getLesDimensions2() as $lesD2) {
            $pdf->AjouterDimension($lesD2);
        }
    }



    $pdf->Output();
} else {
    echo "pas de connexion";
    exit();
}
?>